package com.han.school.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.han.school.mapper.StudentMapper;
import com.han.school.pojo.Student;
import com.han.school.service.StudentService;
import com.han.school.vo.StudentVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;

@Service
public class StudentServiceImpl implements StudentService {
    @Autowired
    private StudentMapper studentMapper;

    @Override
    public PageInfo<StudentVo> findAllStu(StudentVo studentVo) {
        PageHelper.startPage(studentVo.getPage(),studentVo.getLimit());
        List<StudentVo> allStu = studentMapper.findAllStu(studentVo);
        PageInfo<StudentVo> student = new PageInfo<>(allStu);
        return student;
    }

    @Override
    public PageInfo<StudentVo> findAllStu1(StudentVo studentVo) {
        PageHelper.startPage(studentVo.getPage(),studentVo.getLimit());
        List<StudentVo> allStu = studentMapper.findAllStu1(studentVo);
        PageInfo<StudentVo> student = new PageInfo<>(allStu);
        return student;
    }

    @Override
    public StudentVo findAllStuById(int id) {
        StudentVo allStuById = studentMapper.findAllStuById(id);
        return allStuById;
    }

    @Override
    public Integer addStu(Student student) {
        return  studentMapper.addStu(student);
    }

    @Override
    public Integer deleteStu(StudentVo studentVo) {
        return null;
    }

    @Override
    public Integer updateStu(StudentVo studentVo) {
        Integer integer = studentMapper.updateStu(studentVo);
        return integer;
    }
}
